final class Sounds {
	private static byte[] aByteArray327;
	public static final int[] anIntArray326 = new int[5000];
	private static final Sounds[] aSoundsArray325s = new Sounds[5000];
	private static Packet buffer;
	private final Class6[] class6;
	private int anInt330;
	private int anInt331;

	public static Packet method241(int i, int j) {
		if (Sounds.aSoundsArray325s[j] != null) {
			Sounds sounds = Sounds.aSoundsArray325s[j];
			return sounds.method244(i);
		} else {
			return null;
		}
	}

	public static void unpack(Packet buffer) {
		Sounds.aByteArray327 = new byte[0x6baa8];
		Sounds.buffer = new Packet(Sounds.aByteArray327);
		Class6.method166();
		do {
			int j = buffer.getUnsignedShort();
			if (j == 65535) {
				return;
			}
			Sounds.aSoundsArray325s[j] = new Sounds();
			Sounds.aSoundsArray325s[j].method242(buffer);
			Sounds.anIntArray326[j] = Sounds.aSoundsArray325s[j].method243();
		} while (true);
	}

	private void method242(Packet buffer) {
		for (int i = 0; i < 10; i++) {
			int j = buffer.getUnsignedByte();
			if (j != 0) {
				buffer.offset--;
				class6[i] = new Class6();
				class6[i].method169(buffer);
			}
		}
		anInt330 = buffer.getUnsignedShort();
		anInt331 = buffer.getUnsignedShort();
	}

	private int method243() {
		int j = 0x98967f;
		for (int k = 0; k < 10; k++) {
			if ((class6[k] != null) && (class6[k].anInt114 / 20 < j)) {
				j = class6[k].anInt114 / 20;
			}
		}
		if ((anInt330 < anInt331) && (anInt330 / 20 < j)) {
			j = anInt330 / 20;
		}
		if ((j == 0x98967f) || (j == 0)) {
			return 0;
		}
		for (int l = 0; l < 10; l++) {
			if (class6[l] != null) {
				class6[l].anInt114 -= j * 20;
			}
		}
		if (anInt330 < anInt331) {
			anInt330 -= j * 20;
			anInt331 -= j * 20;
		}
		return j;
	}

	private Packet method244(int i) {
		int k = method245(i);
		Sounds.buffer.offset = 0;
		Sounds.buffer.putInt(0x52494646);
		Sounds.buffer.putLEInt(36 + k);
		Sounds.buffer.putInt(0x57415645);
		Sounds.buffer.putInt(0x666d7420);
		Sounds.buffer.putLEInt(16);
		Sounds.buffer.putLEShort_duplicate(1);
		Sounds.buffer.putLEShort_duplicate(1);
		Sounds.buffer.putLEInt(22050);
		Sounds.buffer.putLEInt(22050);
		Sounds.buffer.putLEShort_duplicate(1);
		Sounds.buffer.putLEShort_duplicate(8);
		Sounds.buffer.putInt(0x64617461);
		Sounds.buffer.putLEInt(k);
		Sounds.buffer.offset += k;
		return Sounds.buffer;
	}

	private int method245(int i) {
		int j = 0;
		for (int k = 0; k < 10; k++) {
			if ((class6[k] != null) && (class6[k].anInt113 + class6[k].anInt114 > j)) {
				j = class6[k].anInt113 + class6[k].anInt114;
			}
		}
		if (j == 0) {
			return 0;
		}
		int l = (22050 * j) / 1000;
		int i1 = (22050 * anInt330) / 1000;
		int j1 = (22050 * anInt331) / 1000;
		if ((i1 < 0) || (i1 > l) || (j1 < 0) || (j1 > l) || (i1 >= j1)) {
			i = 0;
		}
		int k1 = l + (j1 - i1) * (i - 1);
		for (int l1 = 44; l1 < k1 + 44; l1++) {
			Sounds.aByteArray327[l1] = -128;
		}
		for (int i2 = 0; i2 < 10; i2++) {
			if (class6[i2] != null) {
				int j2 = (class6[i2].anInt113 * 22050) / 1000;
				int i3 = (class6[i2].anInt114 * 22050) / 1000;
				int ai[] = class6[i2].method167(j2, class6[i2].anInt113);
				for (int l3 = 0; l3 < j2; l3++) {
					Sounds.aByteArray327[l3 + i3 + 44] += (byte) (ai[l3] >> 8);
				}
			}
		}
		if (i > 1) {
			i1 += 44;
			j1 += 44;
			l += 44;
			int k2 = (k1 += 44) - l;
			for (int j3 = l - 1; j3 >= j1; j3--) {
				Sounds.aByteArray327[j3 + k2] = Sounds.aByteArray327[j3];
			}
			for (int k3 = 1; k3 < i; k3++) {
				int l2 = (j1 - i1) * k3;
				System.arraycopy(Sounds.aByteArray327, i1, Sounds.aByteArray327, i1 + l2, j1 - i1);
			}
			k1 -= 44;
		}
		return k1;
	}

	private Sounds() {
		class6 = new Class6[10];
	}
}
